const double pii = (double)(2.)*acos(0);

struct Rect {
    int x1,x2,y1,y2;
    Rect(int x1_=0, int x2_=0, int y1_=0,int y2_=0):
        x1(x1_),x2(x2_),y1(y1_),y2(y2_) {
        ;
    }
    void Format() {
        if(this->x1>this->x2)swap(this->x1,this->x2);
        if(this->y1>this->y2)swap(this->y1,this->y2);
    }
 
};
int Area(Rect A) {
    return ((A.x2-A.x1)) * ( (A.y2-A.y1) );
}
Rect Intersection(Rect A, Rect B) {
    if( A.y2<B.y1 || A .y1>B.y2 || A.x2 < B.x1 || A.x1 > B.x2) {
        return Rect(0,0,0,0);
    }
 
    flag=true;
    return Rect( max(A.x1,B.x1), min(A.x2,B.x2),
                 max(A.y1,B.y1), min(A.y2,B.y2)
               );
}